package com.ro.orderservice.controller;

import com.ro.commonmodule.entity.Order;
import com.ro.orderservice.feignClient.FeignServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/order")
@RefreshScope
public class OrderController {

    @Value("${config.info}")
    String info;

    @Autowired
    private FeignServer myserver;


    @GetMapping(value = "/test")
    public String test() {
        return "this is a order-service";
    }

    @GetMapping(value = "/test/getinfo")
    public String getinfo() {
        return info;
    }


    @PostMapping(value = "/add")
    public String add() {
        Order order = new Order();
        order.setId("10");
        order.setProductName("hero");
        return myserver.addPoint(order);
    }

    @PostMapping(value = "/add2")
    public String add2() {
        return myserver.addPoint2("hero2");
    }
}
